package cn.tedu.scalaoop

/**
 * @author Amos
 * @date 2022/5/17
 */

trait Sing {
  var song:String = "孤勇者"
  var song1:String

  def sing(): Unit ={
    println("我正在唱歌")
  }
}

trait Dance {
  def dance():Unit
}

trait Fly {
  def fly()={
    println("I can fly")
  }
}

class Person2 extends Sing with Dance {
  override var song1: String = "两只老虎"

  override def dance(): Unit = {
    println("我正在跳踢踏舞")
  }
}

object TraitTest {
  def main(args: Array[String]): Unit = {
    val person = new Person2
    person.sing()
    person.dance()

    // 动态混入特质
    val superman = new Person2 with Fly
    superman.dance()
    superman.dance()
    superman.fly()
  }
}